package org.agile2soft.nexoma.core.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;

@Entity
@Table(name="SERVICE_OPTION",uniqueConstraints = @UniqueConstraint(columnNames = {"SER_ID","SEO_ID"}))
public class ServiceOption {

    private Integer id;
    private String name;
    private String url;
    private Service service;

    public ServiceOption() {
    }

    public ServiceOption(String name, String url, Service service) {
        this.name = name;
        this.url= url;
        this.service = service;
    }

    public String toString() {
        return String.format("[Option %s,%s,%s]",id,name,url);
    }

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="SEO_ID",nullable=false,updatable=false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name="SEO_NAME",unique=true,nullable=false,length=30)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name="SEO_URL",nullable=true,length=200)
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SER_ID",nullable=false,updatable=false)
    public Service getService() {
        return this.service;
    }

    public void setService(Service service) {
        this.service=service;
    }

}
